home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1998 / MacHack 1998.toast / The Hacks! / COSEmulator / COSEmulator- SRC / src / DifferenceCloud.cpp < prev    next >
Encoding:
Text File  |  1998-06-21  |  4.7 KB  |  195 lines  |  [TEXT/CWIE]

  1. //===================================================================
  2. //=======================  Headers        =============================
  3.  
  4. #include "DifferenceCloud.h"
  5. #include "GameUtilities.h"
  6. #include "Screen.h"
  7.  
  8. //===================================================================
  9. //=======================  Globals        =============================
  10.  
  11.  
  12. //===================================================================
  13. //=======================  #define        =============================
  14.  
  15.  
  16. //===================================================================
  17. //=======================  Function Prototypes    =====================
  18.  
  19. /*----------------------------------------------------------------------------\
  20.  
  21.     DifferenceCloud :: Constructor
  22.  
  23. \----------------------------------------------------------------------------*/
  24.     DifferenceCloud :: DifferenceCloud( void )
  25.                     :  Window()
  26. {
  27.     
  28. }
  29.  
  30. /*----------------------------------------------------------------------------\
  31.  
  32.     DifferenceCloud :: Init
  33.  
  34. \----------------------------------------------------------------------------*/
  35. Boolean    DifferenceCloud :: Init( void )
  36. {
  37.     width = 695;
  38.     height = 711;
  39.     if( window.NewBuff( width , height ) )
  40.     {
  41.         OffScreenBuff    backGround;
  42.         
  43.         backGround.LoadPicBuff( 140 );
  44.         
  45.         DrawPicture( &backGround , &backGround.GetBoundsSize(), 
  46.                      &window , &window.GetBoundsSize() );
  47.         
  48.         screenLoc.left = 80;
  49.         screenLoc.top = 22;
  50.         screenLoc.right = screenLoc.left + width;
  51.         screenLoc.bottom = screenLoc.top + height;
  52.         
  53.         return true;
  54.     }
  55.     
  56.     return false;
  57. }
  58.  
  59. /*----------------------------------------------------------------------------\
  60.  
  61.     DifferenceCloud :: HandleMouseClick
  62.  
  63. \----------------------------------------------------------------------------*/
  64. void    DifferenceCloud :: HandleMouseClick( Boolean down , point where )
  65. {
  66.     if( down )
  67.     {
  68.         draging = true;
  69.         start = where;
  70.         
  71.         where.x -= screenLoc.left;
  72.         where.y -= screenLoc.left;
  73.         
  74.     }
  75.     else
  76.     {
  77.         
  78.         if( draging )
  79.         {
  80.             screen.AddRectToUpdate( screenLoc );
  81.             
  82.             MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  83.  
  84.             screen.AddRectToUpdate( screenLoc );
  85.             
  86.             draging = false;
  87.         }
  88.     }
  89. }
  90.  
  91. /*----------------------------------------------------------------------------\
  92.  
  93.     DifferenceCloud :: HandleMouseMove
  94.  
  95. \----------------------------------------------------------------------------*/
  96. void    DifferenceCloud :: HandleMouseMove( point where )
  97. {
  98.     if( draging )
  99.     {
  100.         screen.AddRectToUpdate( screenLoc );
  101.         
  102.         MyOffSetRect( &screenLoc , where.x - start.x , where.y - start.y );
  103.         start = where;
  104.         
  105.         screen.AddRectToUpdate( screenLoc );
  106.     }
  107. }
  108.  
  109. /*----------------------------------------------------------------------------\
  110.  
  111.     DifferenceCloud :: PointInWindow
  112.  
  113. - just saids if the point it inside the window area or not
  114. \----------------------------------------------------------------------------*/
  115. Boolean    DifferenceCloud :: PointInWindow( point where )
  116. {
  117.     return SectPtRect( where , screenLoc );
  118. }
  119.  
  120. /*----------------------------------------------------------------------------\
  121.  
  122.     DifferenceCloud :: Active
  123.  
  124. \----------------------------------------------------------------------------*/
  125. Boolean    DifferenceCloud :: Front( void )
  126. {
  127.     return( front );
  128. }
  129.  
  130. /*----------------------------------------------------------------------------\
  131.  
  132.     DifferenceCloud :: SetFront
  133.  
  134. \----------------------------------------------------------------------------*/
  135. void    DifferenceCloud :: SetFront( Boolean f )
  136. {
  137.     if( f != front )
  138.     {
  139.         front = f;
  140.         screen.AddRectToUpdate( screenLoc );
  141.     }
  142. }
  143.  
  144. /*----------------------------------------------------------------------------\
  145.  
  146.     DifferenceCloud :: DrawToScreen
  147.  
  148. \----------------------------------------------------------------------------*/
  149. void    DifferenceCloud :: DrawToScreen( rect *where , Boolean backGround )
  150. {
  151.     if( front && !backGround )
  152.     {
  153.         if( where == NULL )
  154.         {
  155.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  156.                         NULL , 0 , 0 , 0 );
  157.         }
  158.         else
  159.         {
  160.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  161.                         where , 0 , 0 , 0 );
  162.         }
  163.     }
  164.     else
  165.     {
  166.         if( where == NULL )
  167.         {
  168.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  169.                         NULL , kDrawTint , 16 , 0xffff );
  170.         }
  171.         else
  172.             screen.DrawGeneric( &window , &window.GetBoundsSize() , &screenLoc ,
  173.                         where , kDrawTint , 16 , 0xffff );
  174.     }
  175. }
  176.  
  177. /*----------------------------------------------------------------------------\
  178.  
  179.     DifferenceCloud :: DoJunk
  180.  
  181. \----------------------------------------------------------------------------*/
  182. void    DifferenceCloud :: DoJunk( void )
  183. {
  184.     OffScreenBuff    backGround;
  185.     rect            where;
  186.     
  187.     MySetRect( &where , 6 , 22 , 673 , 688 );
  188.         
  189.     backGround.LoadPicBuff( 141 );
  190.     
  191.     DrawPicture( &backGround , &backGround.GetBoundsSize(), 
  192.              &window , &where );
  193.         
  194.     screen.AddRectToUpdate( screenLoc );
  195. }